/*
 * Copyright (C) 2011-2021 Intel Corporation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *   * Neither the name of Intel Corporation nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
'use strict';

const swaggerAutogen = require('swagger-autogen')();

const outputFile = '../swagger.json';
const endpointsFiles = ['../src/routes/*.js', '../src/handlers/*.js'];

const doc = {
  info: {
    version:     '1.0.0',
    title:       'Quote Verification Service',
    description: 'Documentation automatically generated from comments in QVS code'
  },
  host:        'localhost:8799',
  basePath:    '/',
  schemes:     ['https'],
  consumes:    ['application/json'],
  produces:    ['application/json'],
  definitions: {
    AttestationVerificationReport: {
      id:                      '123456789',
      timestamp:               '2023-03-07T10:25:06Z',
      version:                 5,
      isvQuoteStatus:          'TCB_OUT_OF_DATE',
      isvQuoteBody:            'AwACAAAAAAAJAA0Ak5pyM/ecTKmUCg2zlX8GBwpMmllf9LxxjKAqXOfUHBcAAAAABwcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAADAAAAAAAAAIzmaws6v/tSdHrNsTFmxI5zFvxjH4wr0ekGjAq1DDemAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5u0tV+IjIYPSpVgzJgDxwEf9YM81aeUo/X9XHg9C9wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
      nonce:                   'ABCDEABCDEABCDEABCDEABCDEABCDE12',      
      advisoryURL:             'https://security-center.intel.com',
      advisoryIDs:             ['INTEL-SA-68299', 'INTEL-SA-88618', 'INTEL-SA-89971'],
      tcbEvaluationDataNumber: 0,
      tcbDate:                 '2023-03-07T10:10:06Z',
      tcbComponentsOutOfDate:  [
        {
          category: 'CATEGORY01',
          type:     'TYPE01'
        }
      ],
      teeType:         'SGX_SCALABLE',
      attestationType: 'ECDSA',
      configuration:   [
        'DYNAMIC_PLATFORM'
      ]
    },
    AttestationEvidencePayload: {
      $isvQuote: 'AwACAAAAAAAJAA0Ak5pyM/ecTKmUCg2zlX8GBwpMmllf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zUwWld3Z1UwZFlJRkp2YjNRZ1EwRXhHakFZQmdOVkJBb01FVWx1ZEdWc0lFTnZjbkJ2Y21GMAphVzl1TVJRd0VnWURWUVFIREF0VFlXNTBZU0JEYkdGeVlURUxNQWtHQTFVRUNBd0NRMEV4Q3pBSkJnTlZCQVlUCkFsVlRNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUVDNm5Fd01ESVlaT2ovaVBXc0N6YUVLaTcKMU9pT1NMUkZoV0dqYm5CVkpmVm5rWTR1M0lqa0RZWUwwTXhPNG1xc3lZamxCYWxUVll4RlAyc0pCSzV6bEtPQgp1ekNCdURBZkJnTlZIU01FR0RBV2dCUWlaUXpXV3AwMGlmT0R0SlZTdjFBYk9TY0dyREJTQmdOVkhSOEVTekJKCk1FZWdSYUJEaGtGb2RIUndjem92TDJObGNuUnBabWxqWVhSbGN5NTBjblZ6ZEdWa2MyVnlkbWxqWlhNdWFXNTAKWld3dVkyOXRMMGx1ZEdWc1UwZFlVbTl2ZEVOQkxtUmxjakFkQmdOVkhRNEVGZ1FVSW1VTTFscWROSW56ZzdTVgpVcjlRR3prbkJxd3dEZ1lEVlIwUEFRSC9CQVFEQWdFR01CSUdBMVVkRXdFQi93UUlNQVlCQWY4Q0FRRXdDZ1lJCktvWkl6ajBFQXdJRFNRQXdSZ0loQU9XLzVRa1IrUzlDaVNEY05vb3dMdVBSTHNXR2YvWWk3R1NYOTRCZ3dUd2cKQWlFQTRKMGxySG9NcytYbzVvL3NYNk85UVd4SFJBdlpVR09kUlE3Y3ZxUlhhcUk9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KAA==',
      nonce:     'ABCDEABCDEABCDEABCDEABCDEABCDE12'
    },
    PositiveHealthReport: {
      status:          'OK',
      version:         '1.0.0',
      lastChecked:     '2023-03-07T10:30:29.282Z',
      componentStatus: {
        VerificationCryptoService: {
          status:      'OK',
          version:     '0.0.1',
          lastChecked: '2023-03-07T11:22:22.690Z'
        },
        QuoteVerificationLibrary: {
          status:      'OK',
          version:     '1.0.0', 
          lastChecked: '2023-03-07T11:22:22.686Z'
        }
      },
    },
    NegativeHealthReport: {
      status:          'FAILED',
      version:         '1.0.0',
      lastChecked:     '2023-03-07T10:30:29.282Z',
      componentStatus: {
        VerificationCryptoService: {
          status:      'FAILED',
          version:     '0.0.1',
          lastChecked: '2023-03-07T11:22:22.690Z'
        },
        QuoteVerificationLibrary: {
          status:      'OK',
          version:     '1.0.0',
          lastChecked: '2023-03-07T11:22:22.686Z'
        }
      }
    }
  }
};

swaggerAutogen(outputFile, endpointsFiles, doc);
